﻿<!--
	Provided for Informational Purposes Only
	
	Apache 2.0 License
	
	Licensed under the Apache License, Version 2.0 (the "License"); you may
	not use this file except in compliance with the License. You may obtain
	a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
	
	THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
	ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY 
	IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR 
	PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
	
	See the Apache Version 2.0 License for specific language governing
	permissions and limitations under the License.
	-->
<common:LayoutAwarePage
	x:Name="pageRoot"
	x:Class="ContractMeow.ModernApp.Views.MyContractsView"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="using:ContractMeow.ModernApp.Views"
	xmlns:common="using:ContractMeow.ModernApp.Common"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	mc:Ignorable="d">

	<Page.Resources>
		<Style x:Key="ContractTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BasicTextStyle}">
			<Setter Property="Margin" Value="10"/>
			<Setter Property="FontSize" Value="24"/>
			<Setter Property="VerticalAlignment" Value="Center"/>
		</Style>
	</Page.Resources>

	<Page.BottomAppBar>
		<AppBar IsOpen="True">
			<StackPanel Orientation="Horizontal"
						HorizontalAlignment="Right">
				<Button x:Name="New"
						Style="{StaticResource AddAppBarButtonStyle}"/>
			</StackPanel>
		</AppBar>
	</Page.BottomAppBar>

	<Grid Style="{StaticResource LayoutRootStyle}">
		<Grid.RowDefinitions>
			<RowDefinition Height="140"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>

		<!-- Back button and page title -->
		<Grid>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto"/>
				<ColumnDefinition Width="*"/>
				<ColumnDefinition Width="Auto"/>
			</Grid.ColumnDefinitions>
			<Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
			<TextBlock x:Name="pageTitle" Grid.Column="1" Text="My contracts" Style="{StaticResource PageHeaderTextStyle}"/>
			<StackPanel Grid.Column="2" Background="LightGray" Style="{StaticResource CurrentUserHeaderPanel}">
				<Image Source="{Binding CurrentUser.MugshotUrl}" Style="{StaticResource CurrentUserImage}"/>
				<TextBlock Text="{Binding CurrentUser.FullName}" Style="{StaticResource CurrentUserText}"/>
			</StackPanel>
		</Grid>

		<ListView Grid.Row="1"
				  Margin="120, 36, 36, 0"
				  ItemsSource="{Binding MyContracts}"
				  x:Name="MyContractsListView">
			<ListView.ItemTemplate>
				<DataTemplate>
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="50"/>
							<ColumnDefinition Width="*"/>
							<ColumnDefinition Width="Auto"/>
						</Grid.ColumnDefinitions>
						<TextBlock Grid.Column="0" Text="&#xE16D;" Margin="10" FontSize="28" Foreground="#00BCF2" FontFamily="Segoe UI Symbol"/>
						<TextBlock Grid.Column="1" Text="{Binding Name}" Style="{StaticResource ContractTextStyle}"/>
						<TextBlock Grid.Column="2" Text="{Binding Assignees}" Style="{StaticResource ContractTextStyle}" HorizontalAlignment="Right"/>
					</Grid>
				</DataTemplate>
			</ListView.ItemTemplate>
			<ListView.ItemContainerStyle>
				<Style TargetType="ListViewItem">
					<Setter Property="HorizontalContentAlignment" Value="Stretch" />
				</Style>
			</ListView.ItemContainerStyle>
			<ListView.Header>
				<Grid Width="{Binding ActualWidth, ElementName=MyContractsListView}">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="50"/>
						<ColumnDefinition Width="*"/>
						<ColumnDefinition Width="Auto"/>
					</Grid.ColumnDefinitions>
					<TextBlock Grid.Column="0" Text="" Margin="10" FontSize="28" Foreground="Bisque" FontFamily="Segoe UI Symbol"/>
					<TextBlock Grid.Column="1" Text="Contract" Style="{StaticResource ContractTextStyle}"/>
					<TextBlock Grid.Column="2" Text="Assignees" Style="{StaticResource ContractTextStyle}" Margin="10,10,40,10"/>
				</Grid>
			</ListView.Header>
		</ListView>
		
		<VisualStateManager.VisualStateGroups>

			<!-- Visual states reflect the application's view state -->
			<VisualStateGroup x:Name="ApplicationViewStates">
				<VisualState x:Name="FullScreenLandscape"/>
				<VisualState x:Name="Filled"/>

				<!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
				<VisualState x:Name="FullScreenPortrait">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
							<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>

				<!-- The back button and title have different styles when snapped -->
				<VisualState x:Name="Snapped">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
							<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
							<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
			</VisualStateGroup>
		</VisualStateManager.VisualStateGroups>
	</Grid>
</common:LayoutAwarePage>
